package com.itshare.video.mapper;

import com.itshare.video.pojo.po.RolePermission;
import com.itshare.video.pojo.po.RolePermissionExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.session.RowBounds;

public interface RolePermissionMapper {
    long countByExample(RolePermissionExample example);

    int deleteByExample(RolePermissionExample example);

    @Delete({
        "delete from t_role_permission",
        "where auto_id = #{autoId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer autoId);

    @Insert({
        "insert into t_role_permission (role_id, permission_id)",
        "values (#{roleId,jdbcType=INTEGER}, #{permissionId,jdbcType=INTEGER})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="autoId", before=false, resultType=Integer.class)
    int insert(RolePermission record);

    int insertSelective(RolePermission record);

    List<RolePermission> selectByExampleWithRowbounds(RolePermissionExample example, RowBounds rowBounds);

    List<RolePermission> selectByExample(RolePermissionExample example);

    @Select({
        "select",
        "auto_id, role_id, permission_id",
        "from t_role_permission",
        "where auto_id = #{autoId,jdbcType=INTEGER}"
    })
    @ResultMap("com.itshare.video.mapper.RolePermissionMapper.BaseResultMap")
    RolePermission selectByPrimaryKey(Integer autoId);

    int updateByExampleSelective(@Param("record") RolePermission record, @Param("example") RolePermissionExample example);

    int updateByExample(@Param("record") RolePermission record, @Param("example") RolePermissionExample example);

    int updateByPrimaryKeySelective(RolePermission record);

    @Update({
        "update t_role_permission",
        "set role_id = #{roleId,jdbcType=INTEGER},",
          "permission_id = #{permissionId,jdbcType=INTEGER}",
        "where auto_id = #{autoId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(RolePermission record);
}